#include "../macros.hpp"
#include "../uniofwork.hpp"

using lms::unitofwork::UnitOfWork;

//UnitOfWork::UnitOfWork()
//{
//    userRepository = null;
//    customerRepository = null;
//    bookRepository = null;
//}
// 
//
//GenericRepository< lms::entities::Customer >* UnitOfWork::getCustomerRepository() 
//{    
//    if( customerRepository == null )
//       customerRepository = new GenericRepository< lms::entities::Customer >( FILENAME_CUSTOMER );
//    return customerRepository;
//}
//
//GenericRepository< lms::entities::Book >* UnitOfWork::getBookRepository() 
//{
//    if( bookRepository == null )           
//        bookRepository = new GenericRepository< lms::entities::Book >( FILENAME_BOOK );
//    return bookRepository;
//}



UnitOfWork::UnitOfWork()
{
  orderServices = null;
  customerServices = null;
  bookServices = null;
  userRepository = null;
}

OrderServices* UnitOfWork::GetOrderServices()
{
  if( orderServices == null )
    orderServices = new OrderServices();
  return orderServices;
}

CustomerServices* UnitOfWork::GetCustomerServices()
{
  if( customerServices == null )
    customerServices = new CustomerServices();
  return customerServices;
}

BookServices* UnitOfWork::GetBookServices()
{
  if( bookServices == null )
    bookServices = new BookServices();
  return bookServices;
    
}

GenericRepository< lms::entities::User >* UnitOfWork::getUserRepository() 
{
    if( userRepository == null )
        userRepository = new GenericRepository< lms::entities::User >( FILENAME_USER );
    return userRepository;
}
